<template>
  <u-card v-if="item" padding="20rpx 30rpx" margin="20rpx 30rpx" :border="false" class="item" :show-head="false">
    <template #body>
      <view class="item-body">
        <view class="flex">
          <view class="flex-1">{{{'hongbao':'红包', 'chongzhi':'充值'}[item.type]}}</view>
          <text style="font-size: 32rpx;font-weight: 700;" :style="item.money<0?'color: #f00;':'color: green;'">{{item.money>0?'+'+item.money:item.money}}</text>
        </view>
      </view>
      <view class="item-footer">
        <text style="color: #999;font-size: 24rpx;">时间：{{dateFormat(item.addtime)}}</text>
      </view>
    </template>
  </u-card>
</template>
<script lang="ts" setup>
import dayjs from 'dayjs';
import { computed, type PropType } from 'vue';

const props = defineProps({
  item: {
    type: Object as PropType<IMoneyLogItem>,
  }
})

// 格式化时间
const dateFormat = computed(() => {
  return (date: number) => dayjs(date*1000).format('YYYY-MM-DD HH:mm')
})

</script>

<style lang="scss" scoped>

</style>